unit uDZWSnetbs;

interface

uses
  uDZWinSock2;

const
  NETBIOS_NAME_LENGTH = 16;

type
  SOCKADDR_NB = record
    snb_family: Smallint;
    snb_type: Word;
    snb_name: array[0..NETBIOS_NAME_LENGTH - 1] of AnsiChar;
  end;
  PSOCKADDR_NB = ^SOCKADDR_NB;
  LPSOCKADDR_NB = ^SOCKADDR_NB;
  TSockAddrNB = SOCKADDR_NB;
  PSockAddrNB = LPSOCKADDR_NB;

const
  NETBIOS_UNIQUE_NAME = $0000;
  NETBIOS_GROUP_NAME = $0001;
  NETBIOS_TYPE_QUICK_UNIQUE = $0002;
  NETBIOS_TYPE_QUICK_GROUP = $0003;

procedure SET_NETBIOS_SOCKADDR(var SNB: TSockAddrNB; _Type: u_short; const Name:
  AnsiString; Port: Byte);

implementation

procedure SET_NETBIOS_SOCKADDR(var SNB: TSockAddrNB; _Type: u_short; const Name:
  AnsiString; Port: Byte);
var
  I: Integer;
begin
  SNB.snb_family := AF_NETBIOS;
  SNB.snb_type := _Type;
  for I := 0 to NETBIOS_NAME_LENGTH - 1 do
    SNB.snb_name[I] := ' ';
  I := 0;
  while I < NETBIOS_NAME_LENGTH - 1 do
  begin
    if SNB.snb_name[I] = #0 then
      Break;
    SNB.snb_name[I] := SNB.snb_name[I + 1];
    Inc(I);
  end;
  SNB.snb_name[NETBIOS_NAME_LENGTH - 1] := AnsiChar(Port);
end;

end.

